import request from '../../utils/request';

// 菜单管理相关 API

// 更新菜单
export const updateMenu = (data: any) => {
    return request({
        url: '/system/api/menu/update',
        method: 'put',
        data
    });
};

// 保存菜单
export const saveMenu = (data: any) => {
    return request({
        url: '/system/api/menu/save',
        method: 'post',
        data
    });
};

// 根据ID获取菜单
export const getMenuById = (id: string) => {
    return request({
        url: `/system/api/menu/${id}`,
        method: 'get'
    });
};

// 获取菜单树
export const getMenuTree = () => {
    return request({
        url: '/system/api/menu/tree',
        method: 'get'
    });
};

// 分页查询菜单
export const getMenuPage = (params: any) => {
    return request({
        url: '/system/api/menu/page',
        method: 'get',
        params
    });
};

// 获取菜单列表
export const getMenuList = () => {
    return request({
        url: '/system/api/menu/list',
        method: 'get'
    });
};

// 根据组ID获取菜单
export const getMenuByGroupId = (groupId: string) => {
    return request({
        url: `/system/api/menu/group/${groupId}`,
        method: 'get'
    });
};

// 删除菜单
export const deleteMenu = (id: string) => {
    return request({
        url: `/system/api/menu/${id}`,
        method: 'delete'
    });
};
